<!doctype html>
<html class="no-js">
<head>
	<title>订单管理</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
<!--     <link rel="icon" type="image/png" href="../assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="../assets/i/app-icon72x72@2x.png"> -->
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="../assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="../assets/css/admin.css">
    <link rel="stylesheet" href="../assets/js/layui/css/layui.css" media="all" />
   
    <style type="text/css">
    .page{float: right;}
    </style>

</head>

<!--[if lte IE 9]><p class="browsehappy">升级你的浏览器吧！ <a href="http://se.360.cn/" target="_blank">升级浏览器</a>以获得更好的体验！</p>
<![endif]-->


</head>

<body>

    <div class=" admin-content">

 
       <!--  <div class="am-popup am-popup-inner" id="my-popups"> 

            <div class="am-popup-hd">
                <h4 class="am-popup-title">修改栏目名称</h4>
                <span data-am-modal-close
                      class="am-close">&times;</span>
            </div>

            <div class="am-popup-bd">


                <form class="am-form tjlanmu">


                    <div class="am-form-group">
                        <div class="zuo">栏目名称：</div>
                        <div class="you">
                            <input type="email" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入标题">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <div class="zuo">栏目关键词：</div>
                        <div class="you">
                            <input type="password" class="am-input-sm" id="doc-ipt-pwd-1" placeholder="请输入关键词">
                        </div>
                    </div>
                    <div class="am-form-group am-cf">
                        <div class="zuo">栏目描述：</div>
                        <div class="you">
                            <textarea class="" rows="2" id="doc-ta-1"></textarea>
                        </div>
                    </div>
                    <div class="am-form-group am-cf">
                        <div class="zuo">栏目图片：</div>
                        <div class="you" style="height: 45px;">
                            <input type="file" id="doc-ipt-file-1">
                            <p class="am-form-help">请选择要上传的文件...</p>
                        </div>
                    </div>
                    <div class="am-form-group am-cf">
                        <div class="zuo">简介：</div>
                        <div class="you">
                            <textarea class="" rows="2" id="doc-ta-2"></textarea>
                        </div>
                    </div>
                    <div class="am-form-group am-cf">
                        <div class="zuo">状态：</div>
                        <div class="you" style="margin-top: 3px;">
                            <label class="am-checkbox-inline">
                                <input type="checkbox" value="option1">
                                显示 </label>
                            <label class="am-checkbox-inline">
                                <input type="checkbox" value="option2">
                                隐藏 </label>

                        </div>
                    </div>
                    <div class="am-form-group am-cf">
                        <div class="you">
                            <p>
                                <button type="submit" class="am-btn am-btn-success am-radius">提交</button>
                            </p>
                        </div>
                    </div>
                </form>


            </div>


        </div>  -->


        <div class="admin-biaogelist">

            <div class="listbiaoti am-cf">
                <ul class="am-icon-flag on"> 订单列表</ul>

                <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">订单列表</a></dl>

                <!--<dl>
                    <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus"> 补充线订单</button>
                </dl>
                这里打开的是新页面-->


            </div>	
			<div id="test">

            <form class="am-form am-g" >
                <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped am-table-hover">
                    <thead>
                    <tr class="am-success">
                        <th class="table-check"><input type="checkbox"/></th>

                        <th class="table-id">序号</th>
                        <th class="table-title">电影名称</th>
                        <th class="table-type">购票数量</th>
                        <th class="table-author am-hide-sm-only">购票用户</th>
                        <th class="table-author am-hide-sm-only">购票价格</th>
                        <th class="table-date am-hide-sm-only">购票日期</th>
                        <th width="130px" class="table-set">操作</th>
                    </tr>
                    </thead>
                    <tbody id="order_List"></tbody>
                    
                </table>
				<div class="page" id="page_order" ></div>
           
                <hr/>
               
            </form>
			</div>
        </div>
		
    </div>
   
    <script id="template_order" type="text/html">
			{{# for(var i=0;i<d.length;i++){ }}
			<tr>
                   <td><input type="checkbox"/></td>
                   <td ><span id="orderId">{{ i+1 }}</span></td>
                   <td id="movieName"> {{d[i].schedule.movieName }} </td>
                   <td id="movieCount"> {{d[i].count }} </td>
                   <td id="userName" class="am-hide-sm-only"> {{d[i].userName}}</td>
                   <td id="adjustedPrice" class="am-hide-sm-only">{{d[i].adjustedPrice}}</td>
                   <td id="buyDate" class="am-hide-sm-only">{{d[i].buyDate}}</td>
                   <td>

                   		<div class="am-btn-toolbar">
                   			<div class="am-btn-group am-btn-group-xs">
                  				 <a class="am-btn am-btn-default am-btn-xs am-text-success am-round" onclick="getOrderdetail({{d[i].id }})"><span
                   					class="am-icon-search" title="查看订单详情" ></span></a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary am-round"
                                            data-am-modal="{target: '#my-popups'}" title="修改订单"   onclick=" orderUpdate({{d[i].id }})"><span
                                            class="am-icon-pencil-square-o"></span></a>
                                    <a class="am-btn am-btn-default am-btn-xs am-text-danger am-round"   onclick=" delOrder({{d[i].id }})"
                                            title="删除订单"><span class="am-icon-trash-o"></span></a>
                             </div>
                        </div>
                    </td>
             </tr>
		
		{{# } }}
			
	
	</script>
	

  
 <script  type="text/javascript">
    	//页面加载时就运行
    	
    	$(function(){
    		getOrderCount();
    		
    	});
    	
    	//获取订单总数
    	function getOrderCount(){
    		$.ajax({
    			url:"/moviesMaven/order/getOrderCount.htm",
    			dataType:"json",
    			success:function(data){
    				renderPage_order(data);
    			},
    			error:function(){
    				layer.msg("查询订单总数出错！");
    			}
    			
    		});
    	}
    		
    	//渲染分页元素
    	function renderPage_order(data){
    			var count = data.result; //总数
    			var size = 10; //每页行数
    			
    			//渲染分页
    			layui.use("laypage", function() {
    				var laypage = layui.laypage;
    				
    				laypage.render({
    					
    					elem : "page_order",
    					count :count,
    					limit : size,
    					theme : "#4287c2",
    					jump : function(obj, first) {
							
							getdata_order(obj.curr,size);
							
						}
	
    				});

    			});
    	}
    		
    	
    	//获取订单数据
    	function getdata_order(nowPage,size){
    	
    	 $.ajax({
                url:"/moviesMaven/order/getOrderList.htm",
                dataType:"json",
                data:{
					"nowPage" : nowPage,
					"size" : size
					},
                success:function (data) {

                    if(data.success){
                    	
                    	/* 渲染页面 */
	 					renderData_order(data.result);
                    	
                   		 
                    }else {
                        layer.msg(data.message);
                    }
                },
                error:function () {
                    layer.msg("查询出错");
                }
            }); 

    	}
    	
    	//模板引擎渲染页面
    	function  renderData_order(data){
    		
    		layui.use("laytpl",function(){
    			var laytpl = layui.laytpl;
    			
    			var template_order = $("#template_order").html();
    			laytpl(template_order).render(data,function(html){
    				$("#order_List").html(html);
			
    			});
    			

    		});

    	}
    	//修改订单
    	function orderUpdate(orderId){
    		getRoleId(function(rs){
    			if(rs==1){
    				layer.open({
    	    			  type: 2,
    	    			  title: '修改订单',
    	    			  shadeClose: true,
    	    			  shade: 0.8,
    	    			  area: ['50%', '300px'],
    	    			  content: 'order_update.html?orderId='+orderId+'' //iframe的url
    	    			}); 
    			}else{
    				layer.msg("您没有权限修改，请联系超级管理员")
    			}
    		});	
    	}
    	//查看订单详情
    	function getOrderdetail(orderId){
    		layer.open({
  			  type: 2,
  			  title: '订单详情',
  			  shadeClose: true,
  			  shade: 0.8,
  			  area: ['50%', '300px'],
  			  content: 'order_detail.html?orderId='+orderId+'' //iframe的url
  			}); 
    		
    	}
    	
    	//删除订单
    	function delOrder(orderId){
    		getRoleId(function(rs){
    			if(rs==1){
    				layer.open({
    					title:"确认",
    					icon:3,
    					content: "您确定要删除此订单吗？ ",
    					btn: ['确定','取消'],
    					yes:function(index){	
    						 $.ajax({   //删除订单
    	    						url:"/moviesMaven/order/deleteOrder.htm",
    	    						dataType:"json",
    	    						data:{"orderId":orderId},
    	    						success:function (data) {
    	    							if(data.success){
    	    								alert("删除订单成功！");
    	    						
    	    							}else{
    	    								
    	    								alert(data.message);
    	    								
    	    							}
    	    							layer.close(index);
    	    							getOrderCount();
    	    						},
    	    						error:function(XMLHttpRequest, textStatus, errorThrown){
    	    							
    	    						  alert(textStatus+":"+XMLHttpRequest.status);
    	    							
    	    						}
    	    						
    	    					}); 
    					},
    				btn2: function(){
    					
    				 },
    				cancel:function(){
    					
    				}
    			});
    				 
    			}else{
    				layer.msg("您没有权限修改，请联系超级管理员")
    			}
    		});	
    		
    	}

    
    </script>
    
    
    
    
    
    
    
    <!-- jQuery实现页面渲染 -->
   <!--  <script type="text/javascript" >
    	/* 页面运行时就加载 */
    	$(function(){ 
    		getData_order();
    	});
    
    	/* 获取订单列表  */
        function getData_order(){
            $.ajax({
                url:"/moviesMaven/order/getOrderList.htm",
                dataType:"json",
                success:function (data) {

                    if(data.success){
                    	
                    	/* 渲染页面 */
	 					renderData_order(data.result);
                   		 
                    }else {
                        layer.msg(data.message);
                    }
                },
                error:function () {
                    layer.msg("查询出错");
                }
            });

        };
     
    	 /* 渲染订单列表    */
    	 var template_order = $("#order_List tr"); //储存每一行的模板数据
     	 function renderData_order(data){
     		$("#order_List tr").remove();
     		for(var i=0; i<data.length;i++){
     			
     			var $tr = $(template_order).clone(); //复制
     			$tr.find("#orderId").text(i+1);
     			$tr.find("#movieName").text(data[i].schedule.movieName);
     			$tr.find("#movieCount").text(data[i].count);
     			$tr.find("#userName").text(data[i].userName);
     			$tr.find("#adjustedPrice").text(data[i].adjustedPrice);
     			$tr.find("#buyDate").text(data[i].buyDate);
     			
     			$("#order_List").append($tr);
     		}
     
     	 }

    </script> -->






</body>
</html>